﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows;
using AlgorithmBox.Script;

namespace AlgorithmBox.FlowCharts
{
	class Input : FlowChartElement
	{
		public string TypeConverter;

		string text;
		public override string Text
		{
			get
			{
				if (AlgorithmExecuter.IsOn)
				{
					InputBox input = new InputBox();
					input.VarName = text;
					input.VarType = TypeConverter;

					if (input.GetVariable())
					{
						string inputString = input.Result;
						return String.Format("{0} = System.{1}({2})",
							text,
							TypeConverter,
							inputString);
					}
					else
					{
						return String.Empty;
					}
				}
				else
					return text;
			}
			set
			{
				text = value;
				this.ContentBlock.Text = value;
			}
		}

		public Input()
		{
			this.RenderTransform = new SkewTransform(-20.0, 0.0);
			this.MinWidth = 80.0;
			this.MinHeight = 50.0;

			this.ContentBlock.LayoutTransform = new SkewTransform(20.0, 0.0);
			this.ContentChanger.LayoutTransform = new SkewTransform(20.0, 0.0);
		}
	}
}
